package com.syn.vr.db.dao;

import androidx.room.Dao;
import androidx.room.Query;

import com.gaoyi.basemodule.basedao.BaseDao;
import com.syn.vr.db.VrDatabase;
import com.syn.vr.db.entity.Record;

import java.util.List;

@Dao
public abstract class RecordDao extends BaseDao<Record> {
    @Query("SELECT * FROM " + VrDatabase.TABLE_RECORD + " WHERE upload = :upload LIMIT :limit")
    public abstract List<Record> query(int upload, int limit);

    @Query("SELECT COUNT(id) FROM " + VrDatabase.TABLE_RECORD + " WHERE createdAt >= :startDate AND createdAt <= :endDate AND projId = :projId GROUP BY cardNumber")
    public abstract List<Integer> queryCount(long startDate, long endDate, String projId);

    @Query("SELECT COUNT(id) FROM " + VrDatabase.TABLE_RECORD + " WHERE cardNumber = :cardNo AND createdAt >= :startDate AND createdAt <= :endDate AND projId = :projId")
    public abstract int queryCountByCardNo(String cardNo,long startDate, long endDate, String projId);
}
